package com.skytech.component.monitor.util;

import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class ChromeBrowser {
    @Value("${chrome.driver.path}")
    public String driverPath;

    public ChromeDriver getChromeDriver(){
        System.setProperty("webdriver.chrome.driver", driverPath);//加载驱动
        /*ChromeDriver driver;*/
        ChromeOptions options = new ChromeOptions();

        options.addArguments("--headless");//为了程序在Linux环境无可视化界面情况下运行
        options.addArguments("--no-sandbox");//为了程序在Linux环境无可视化界面情况下运行
        return new ChromeDriver(options);
    }
}
